﻿<%@ Page Language="C#" %>

<%@ Import Namespace="wojilu" %>
<%@ Import Namespace="wojilu.View" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Domain" %>
<%@ Import Namespace="wojilu.Apps.Qycms.Service" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>#{softtitle}</title>
<link href="#{path.css}ybb/css/baselist.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<link href="#{path.css}ybb/css/all.css?v=#{cssVersion}" rel="stylesheet" type="text/css" />
<link href="#{path.css}ybb/css/formdiv.css?v=#{cssVersion}" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="#{path.js}ybb/js/jquery.js?v=#{jsVersion}"></script>
<script type="text/javascript" src="#{path.js}ybb/js/control.js?v=#{jsVersion}"></script>
<script type="text/javascript" src="#{path.js}ybb/js/form.js?v=#{jsVersion}"></script>
<script type="text/javascript">

	var resizewindow= null;

	window.onresize = function(){
		var h = $(window).height();
		if(resizewindow!=h){
			sizewindow();
			resizewindow=h;
		}
	}

	function sizewindow(){
		var h = $(window).height();
		if(document.getElementById("mainbodybottonauto")){
			$('.managebottonadd').css({height:h-40});
			$('#content').css({height:h-180});
		}
	}
	var templatemain_js_code_empty = "_{templatemain_js_code_empty}";
	var templatemain_js_content_empty = "_{templatemain_js_content_empty}";
	var templatemain_js_copy_ok = "_{templatemain_js_copy_ok}";
	var templatemain_js_copy_no = "_{templatemain_js_copy_no}";
	var iframename = "#{iframename}";
	$(document).ready(function(){
	    var h = '#{iframeheightwindow}';
		$('.managebottonadd').css({height:h-40});
		$('#content').css({height:h-180});
		var options = {
			beforeSubmit: formverify,
			success:saveResponse,
			resetForm: true
		}
		$('#templatecopy').submit(function() {
			$(this).ajaxSubmit(options);
			return false;
		});
	})




	function formverify(formData) {
		var queryString = $.param(formData);
		var get=urlarray(queryString);
		if(get['templatecode'].match(/^[a-z]{1}[a-z0-9_]{1,49}$/g)==null) {
			document.templatecopy.templatecode.focus();
			alert(templatemain_js_code_empty);
			return false;
		}
		if(get['content']==''){
			document.templatecopy.content.focus();
			alert(templatemain_js_content_empty);
			return false;
		}
		parent.windowsdig('Loading', 'iframe:#{load}', '400px', '180px', 'iframe', false);
	}
	function saveResponse(options){
		parent.closeifram();
		if (options=='true'){
			parent.frames[iframename].refresh('selectform','selectall','check_all');
			alert(templatemain_js_copy_ok);
		}else{
			alert(templatemain_js_copy_no);
		}
		parent.onaletdoc()
	}
</script>
</head>

<body>
<form name="templatecopy" id="templatecopy" method="post" action="#{ActionLink}">
<div id="mainbodybottonauto" class="managebottonadd">
	<div class="maindobycontent">
		<div class="suggestion">
			<span class="sugicon"><span class="strong colorgorning2">_{position_title}</span><span class="colorgorningage">_{templatemain_copy_mess}  #{dir}#{filename}  _{templatemain_copy_mess2}#{dir}</span></span>
		</div>
		<div class="manageeditdiv">
			<div class="maneditcontent">
				<table class="formtable">
					<tr class="trstyle2">
						<td width="15%" class="trtitle011">_{templatemain_add_code}</td>
						<td width="85%" class="trtitle02">
							<input type="text" name="templatecode" size="50" maxlength="49" class="infoInput" onblur="checktypename('templatecode',this.value,'<%=link.to(new wojilu.Web.Controller.Admin.Qycms.TemplateController().CheckCode) %>?dir=#{dir}&filename=#{filename}','codeerrid','_{templatemain_js_code_err2}','_{templatemain_js_code_err1}','templatecopysubmit');"/>
						</td>
					</tr>
					<tr class="trstyle2">
						<td width="15%" class="trtitle011"></td>
						<td width="85%" class="trtitle02">
							<span class="cautiontitle" id="codeerrid">_{templatemain_add_code_option}</span>
						</td>
					</tr>
					<tr class="trstyle2">
						<td class="trtitle011">_{templatemain_add_content}</td>
						<td class="trtitle02"><textarea wrap="off" name="content" id="content" style="width:98%" class="smallInput">#{content}</textarea></td>
					</tr>
				</table>
			</div>
		</div>
	</div>
</div>
<div id="downbotton">
	<div id="subbotton">
		<table border="0" width="100%">
			<tr>
				<td id="right"><input type="submit" id="templatecopysubmit" name="Submit" value="_{botton_copy}" class="buttonface" /></td>
				<td id="left" class="padding-left5"><input type="button" name="cancel" onClick="javascript:parent.onaletdoc();" value="_{botton_copy_reset}" class="buttonface" /></td>
			</tr>
		</table>
	</div>
</div>
<input type="hidden" name="dir" value="#{dir}">
<input type="hidden" name="filename" value="#{filename}">
</form>
</body>

</html>